package com.lun.blog.repostory;

import com.lun.blog.pojo.Comment;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author fangLJ
 * @creatTime 2021/3/10
 */
public interface CommentRepository extends JpaRepository<Comment,Long>, JpaSpecificationExecutor<Long> {


    List<Comment> findByBlog_Id(Long blogId);

    long count();

    @Query(value = "SELECT * FROM t_comment WHERE blog_id=?1 AND parent_comment_id IS NULL ORDER BY create_time ASC",nativeQuery = true)
    List<Comment> findComment(Long blogId);

    List<Comment> findByParentComment_Id(Long parentId);
}
